﻿using Main.DataBaseContext;
using Main.dto;
using Main.messageEvent;
using Microsoft.EntityFrameworkCore;
using Prism.Commands;
using Prism.Events;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Animation;

namespace Main.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private readonly BusnessContext busnessContext ;

      

        public MainWindow(BusnessContext busnessContext,IEventAggregator eventAggregator)
        {
            InitializeComponent();

            this.busnessContext = busnessContext;

            // 导航菜单发生改变时，隐藏导航菜单
            leftMenuGrid.SelectionChanged += OpenMenu;
        }

        


        private void OpenMenu(object sender, RoutedEventArgs e)
        {
            DoubleAnimation doubleAnimation = new DoubleAnimation();


            double currentWidth = leftMenuGrid.Width;

            if (currentWidth == 0)
            {
                // 展开抽屉
                doubleAnimation.From = 0;
                doubleAnimation.To = 200;
            }
            else {
                // 关闭抽屉
                doubleAnimation.From = 200;
                doubleAnimation.To = 0;

            }


            doubleAnimation.Duration = TimeSpan.FromMilliseconds(300);

            leftMenuGrid.Visibility = Visibility.Visible;

            leftMenuGrid.BeginAnimation(DataGrid.WidthProperty, doubleAnimation);
            

        }

   
    }
}
